package com.sample.command
{
	import com.sample.remote.Delegates;
	import com.sample.remote.TimeDelegate;
	import com.trg.flex.Callback;
	import com.trg.flex.remote.RemoteCall;
	import com.trg.flex.search.Search;
	
	import mx.collections.ArrayCollection;
	
	public class TimeCommands
	{
		public static function get i():TimeCommands {
			return new TimeCommands();
		}
		
		private var delegate:TimeDelegate = Delegates.timeDelegate;
		
		public function fetchProjectsByUser(userID:Number, rangeStart:Date, rangeEnd:Date, callback:Callback):void {
			var call:RemoteCall = delegate.fetchProjectsByUser(userID, rangeStart, rangeEnd).addResponder(callback);
			call.description = "Loading Projects";
			call.longDescription = "Loading the user's active projects for the week.";
			call.call();
		}
		public function fetchTimeEntryByUser(userID:Number, rangeStart:Date, rangeEnd:Date, callback:Callback):void {
			var call:RemoteCall = delegate.fetchTimeEntryByUser(userID, rangeStart, rangeEnd).addResponder(callback);
			call.description = "Loading Time Entry Data";
			call.longDescription = "Loading the user's time entries for the week.";
			call.call();
		}
		public function batchUpdate(updateList:ArrayCollection, addList:ArrayCollection, deleteList:ArrayCollection, callback:Callback):void {
			var call:RemoteCall = delegate.batchUpdate(updateList, addList, deleteList).addResponder(callback);
			call.description = "Saving Time Entry Data";
			call.call();
		}
		public function searchTimeEntries(search:Search, callback:Callback):void {
			var call:RemoteCall = delegate.searchTimeEntries(search).addResponder(callback);
			call.description = "Loading";
			call.longDescription = "Searching for time entries that meet the given criteria.";
			call.call("overwrite", "timeReports");
		}
	}
}